package org.simple.model;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;

@Entity
@NamedQuery(name = "Weather.byLocation",query="from Weather as w where w.localtion=:localtion")
public class Weather {
	private int id;
	private Location localtion;
	private Condition condition;
	private Wind wind;
	private Atmosphere atmosphere;
	private Date date;
	
	public Weather() {
		super();
	}

	@Id
	@GeneratedValue
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	@ManyToOne()
	public Location getLocaltion() {
		return localtion;
	}

	public void setLocaltion(Location localtion) {
		this.localtion = localtion;
	}

	@OneToOne(mappedBy = "weather" ,cascade = CascadeType.ALL)
	public Condition getCondition() {
		return condition;
	}

	public void setCondition(Condition condition) {
		this.condition = condition;
	}

	@OneToOne(mappedBy = "weather")
	public Wind getWind() {
		return wind;
	}

	public void setWind(Wind wind) {
		this.wind = wind;
	}
	@OneToOne
	public Atmosphere getAtmosphere() {
		return atmosphere;
	}

	public void setAtmosphere(Atmosphere atmosphere) {
		this.atmosphere = atmosphere;
	}

	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	@Override
	public String toString() {
		return "Weather [id=" + id + ", localtion=" + localtion
				+ ", condition=" + condition + ", wind=" + wind
				+ ", atmosphere=" + atmosphere + ", date=" + date + "]";
	}

}
